import http from '@/utils/http'

const BASE_URL = '/website_management/content'

export interface ContentResp {
  id: string
  title: string
  content: string
  picture: string
  categoryId: string
  sort: string
  status: string
  createUser: string
  createTime: string
  updateUser: string
  updateTime: string
  createUserString: string
  updateUserString: string
}
export interface ContentDetailResp {
  id: string
  title: string
  content: string
  picture: string
  categoryId: string
  sort: string
  status: string
  createUser: string
  createTime: string
  updateUser: string
  updateTime: string
  createUserString: string
  updateUserString: string
}
export interface ContentQuery {
  title: string
  categoryId: string
  sort: string
  status: string
  createUser: string
  createTime: string
  sort: Array<string>
}
export interface ContentPageQuery extends ContentQuery, PageQuery {}

/** @desc 查询内容列表 */
export function listContent(query: ContentPageQuery) {
  return http.get<PageRes<ContentResp[]>>(`${BASE_URL}`, query)
}

/** @desc 查询内容详情 */
export function getContent(id: string) {
  return http.get<ContentDetailResp>(`${BASE_URL}/${id}`)
}

/** @desc 新增内容 */
export function addContent(data: any) {
  return http.post(`${BASE_URL}`, data)
}

/** @desc 修改内容 */
export function updateContent(data: any, id: string) {
  return http.put(`${BASE_URL}/${id}`, data)
}

/** @desc 删除内容 */
export function deleteContent(id: string) {
  return http.del(`${BASE_URL}/${id}`)
}

/** @desc 导出内容 */
export function exportContent(query: ContentQuery) {
  return http.download<any>(`${BASE_URL}/export`, query)
}
